package com.sirap.spring.boot.demo.controller.album;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sirap.basic.tool.D;
import com.sirap.basic.util.StrUtil;
import com.sirap.basic.util.XCodeUtil;
import com.sirap.fish.fetchers.SinaSportsImageFetchers;
import com.sirap.fish.fetchers.SinaStoryImageFetchers;
import com.sirap.spring.boot.demo.controller.BaseController;

@Controller
@RequestMapping(value = "/albumsinastory")
public class AlbumSinaStoryController extends BaseController {

	private String router = "SinaStory";
	
	@ResponseBody
    @RequestMapping(value = "/page/{page}", method = RequestMethod.GET)
	public Map<String, Object> listAlbumsByPage(@PathVariable int page, HttpServletRequest request) {
    	D.at();
		Map<String, Object> map = SinaStoryImageFetchers.getAlbumsByPage(page);
		D.pjsp(map);
	
		return map;
    }
    
    @RequestMapping(value = "/list", method = RequestMethod.GET)
	public String listAlbums(HttpServletRequest request, HashMap<String, Object> map) {
    	D.at();
	
    	return StrUtil.occupy("album/album{0}List", router);
    }

    @RequestMapping(value = "/show/{base64url}", method = RequestMethod.GET)
	public String showAlbum(HttpServletRequest request, @PathVariable String base64url, HashMap<String, Object> map) {
    	D.at();
		map.putAll(getAlbumDetail(base64url, SinaStoryImageFetchers.class));
	
    	return StrUtil.occupy("album/album{0}Detail", router);
    }
}
